<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>农污处理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/css/admin.css" media="all">
    <link rel="shortcut icon" href="<%=request.getContextPath()%>/huazhi/hz/favicon.ico"/>
    <link rel="stylesheet" href="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/css/layui.css" media="all">
</head>
<body>



<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-form layui-card-header layuiadmin-card-header-auto">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-form-item" style="margin-bottom: 0px">
                        <label class="layui-form-label">开始日期</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="test-laydate-start">
                        </div>
                        <label class="layui-form-label">结束日期</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="test-laydate-end">
                        </div>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label">操作人员</label>
                    <div class="layui-input-block">
                        <div class="layui-form" lay-filter="operationperson">
                            <select name="key" id="userTid" lay-search>
                                <option value="">请选择</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-inline">
                    <button class="layui-btn" id="search_btn" data-type="reload">查询</button>
                </div>
            </div>
        </div>

        <div class="layui-card-body">
            <table class="layui-hide" id="logTable" lay-filter="logTable"></table>
            <div id="laypage"></div>
        </div>
    </div>
</div>
<input type="hidden" id="curnum" value="1">
<script src="<%=request.getContextPath()%>/huazhi/lib/layui-v2.5.5/layui.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script src="<%=request.getContextPath()%>/huazhi/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['laydate','table','form','log'], function () {
        var laydate = layui.laydate
            , $=layui.$
            , form=layui.form
            , table = layui.table;

        //开始日期
        var insStart = laydate.render({
            elem: '#test-laydate-start',
            theme: 'molv'
            ,done: function(value, date){
                //更新结束日期的最小日期
                insEnd.config.min= lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#test-laydate-end'
            ,min: 0
            ,theme: 'molv'
            ,done: function(value, date){
                //更新开始日期的最大日期
                insStart.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        $.ajax({
            type: "get",
            url: "<%=request.getContextPath()%>/rest/system/getSelectUserList",
            dataType: "json",
            success: function (res) {
                var data = res.data;
                var select = document.getElementById("userTid");
                $.each(data, function (i, n) {
                    select.options.add(new Option(n.username, n.tid));
                })
                form.render('select',"operationperson");
            }
        })

        var  active = {
            reload: function(){  //data-type='reload'
                var userTid = $('#userTid').val();
                var starttime = $('#test-laydate-start').val();
                var endtime = $('#test-laydate-end').val();
                //执行重载
                $("#curnum").val("1");
                table.reload('logTable', { //表格的id
                    where: {
                        key: userTid,
                        starttime:starttime,
                        endtime:endtime,
                        page: 1,
                        limit:10,
                    },
                    text: {
                        none: '暂无相关数据' //默认：无数据。注：该属性为 layui 2.2.5 开始新增
                    }
                })
            }
        };

        $('#search_btn').on('click', function(){ //搜索的id
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>
</body>
</html>